#define TEMP0 (10)
#define TEMP1 (60)
#define ADC0 (297)
#define ADC1 (168)
const int analogOutPin=6;
unsigned char ledLight=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(analogOutPin, OUTPUT);
  //analogReadResolution(12);

}

void loop() {
  int n = analogRead(A0); 
    int tem =convert_adc2temperature(n,ADC0,ADC1,TEMP0,TEMP1);
    analogWrite(analogOutPin, (255 - tem));
  delay(1000);
}

short int convert_adc2temperature(short int ax,short int a0,short int a1,short int temp0,short int temp1)
{
short int tempx;
tempx = temp0+(ax/2-a0)*(temp1-temp0)/(a1-a0);
return tempx;
}


